<%-- 
    Document   : ContactUs
    Created on : Nov 1, 2011, 11:36:38 PM
    Author     : Mr-aUgust
--%>

<%@page pageEncoding="UTF-8"%>
<%@ page language="java" import="javazoom.upload.*,java.util.*" %>
<%@ page session="true" import="java.util.Collection, DAL.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
String im="";
try{
    if (MultipartFormDataRequest.isMultipartFormData(request)) {
        MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
        UploadBean upBean=new UploadBean();
        upBean.setFolderstore(getServletContext().getRealPath("/") + "images\\tour");
        String todo = null;
        if(mrequest!=null) {
            todo = mrequest.getParameter("todo");
            if((todo != null) && (todo.equalsIgnoreCase("upload"))) {
                Hashtable files = mrequest.getFiles();
                if((files != null) && (!files.isEmpty())) {
                    UploadFile file = (UploadFile)files.get("image");
                    if (file != null)
                        im="images/tour/"+file.getFileName();
                    upBean.store(mrequest, "image");
                } else {
                    out.println("<li>No uploaded files");
                }
            }
        } else out.println("<BR> todo="+todo);
    }
}catch (Exception ex){}
%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>East2West Tours and Travels</title>
        
        <script language="javascript" src="../js2/jquery.min.js"></script>       
        <script type="text/javascript" src="../WebContent/jquery/jquery.wysiwyg.js"></script>
        <script type="text/javascript" src="../js2/easyzoom.min.js"></script>  
        
        <script type="text/javascript">        
              
	$(document).ready(function(){
	
			var form=$("#tourPackge");                     
						
			var nameTour=$("#nameTour");
			var nameTourInfor=$("#nameTourInfor");
			
			var duration=$("#duration");
			var durationInfor=$("#durationInfor");
			
			var adultprice=$("#adultprice");
			var adultpriceInfor=$("#adultpriceInfor");
			
			var childprice=$("#childprice");
			var childpriceInfor=$("#childpriceInfor");
			
                         var infor=$("#infor");                   
                        var message=$("#message");						
						
			nameTour.blur(validNameTour);
			nameTour.keyup(validNameTour);			
			duration.blur(validDuration);
			duration.keyup(validDuration);			
			adultprice.blur(validAdultprice);
			adultprice.keyup(validAdultprice);			
			childprice.blur(validChildprice);
			childprice.keyup(validChildprice);
                        
                        infor.blur(validInforTour);
                        infor.keyup(validInforTour);
                        
		
			
				form.submit(function(){
					if(validNameTour() & validDuration() & validAdultprice() & validChildprice() & validInforTour() & validMessage())
					{
						return true;
					}
					else{
						return false;

					}
			 });
				
				
				
				function validNameTour(){
				  if(nameTour.val()==""){
						nameTour.addClass("error");
						nameTourInfor.text("Enter name tour");
						nameTourInfor.addClass("error");
						return false;
					}
					else
					{
					    nameTour.removeClass("error");
						nameTourInfor.text("");
						nameTourInfor.removeClass("error");
						return true;
					}
				
				}
				function validDuration(){
					 if(duration.val()==""){
						duration.addClass("error");
						durationInfor.text("Please enter Duration");
						durationInfor.addClass("error");
						return false;
					}
					else{
					    duration.removeClass("error");
						durationInfor.text("");
						durationInfor.removeClass("error");
						return true;
					}
				}
				
				function validAdultprice(){
				  if(adultprice.val()==""){
						adultprice.addClass("error");
						adultpriceInfor.text("Please enter Adultprice : example : 1200");
						adultpriceInfor.addClass("error");
						return false;
					}
					else if(isNaN(adultprice.val()))
					{
					   adultprice.addClass("error");
						adultpriceInfor.text("Please enter is number");
						adultpriceInfor.addClass("error");
						return false;
					}
					else{
					    adultprice.removeClass("error");
						adultpriceInfor.text("");
						adultpriceInfor.removeClass("error");
						return true;
					}
				
				}
				
				function validChildprice(){
				  if(childprice.val()==""){
						childprice.addClass("error");
						childpriceInfor.text("Please enter Adultprice : example : 1200");
						childpriceInfor.addClass("error");
						return false;
					}
					else if(isNaN(childprice.val()))
					{
					   childprice.addClass("error");
						childpriceInfor.text("Please enter is number");
						childpriceInfor.addClass("error");
						return false;
					}
					
					else{
					    childprice.removeClass("error");
						childpriceInfor.text("");
						childpriceInfor.removeClass("error");
						return true;
					}
				
				}
                                
                              function validInforTour(){
				  if(infor.val()=="")
                                  {
						infor.addClass("error");
						return false;
					}
					else
					{
					    infor.removeClass("error");
					   					
					    return true;
					}
				
				}
                                function validMessage(){
				  if(message.val()==""){
						message.addClass("error");
						
						return false;
					}
					else{
					    message.removeClass("error");
						
						return true;
					}
				
				}
			
                              
	  });
        </script>
        <style type="text/css">
            <!--
.style1 {color: #3366FF}
            -->
        </style>
        
    </head>
    <script type="text/javascript">      
 $(function()
        {
        $("#message").wysiwyg();
        });
    </script>
    <style type="text/css">
        #tourPackge input{
        width: 270px;	
        font-family:Times New Roman, Arial, Verdana, Helvetica, sans-serif;	
        }
        #tourPackge textarea.error{
        background: #f8dbdb;
        border-color: #e77776;
        }
        
        #tourPackge input.error{
        background: #f8dbdb;
        border-color: #e77776;
        }
        #tourPackge span{
        margin-left: 10px;
        color: #6f9ff1;
        font-size: 11px;
        font-style: italic;
        }
        #tourPackge span.error{
        color: #e46c6e;
        }
       #tourPackge #send{
        background: #6f9ff1;
        color: #fff;
        font-weight: 700;
        font-style: normal;
        border: 0;
        cursor: pointer;
        }
        #tourPackge #reset{
        background: #6f9ff1;
        color: #fff;
        font-weight: 700;
        
        border: 0;
        cursor: pointer;
        }
        #tourPackge #send:hover{
        background: #79a7f1;
        }
        #error{
        margin-bottom: 20px;
        border: 1px solid #efefef;
        }        
        
    </style>
    <style type="text/css">
        #easy_zoom{
        width:400px;
        height:280px;	
        border:5px solid #eee;
        background:#fff;
        color:#333;
        position:absolute;
        top:60px;
        left:150px;
        overflow:hidden;
        box-shadow:0 0 10px #777;
        line-height:400px;
        text-align:center;
        }      
            
    </style>
    <body>
        <center>     
            <form action="management.jsp?page=CreateTourPackage" name="formimage" method="post" enctype="multipart/form-data">
                <table width="900px">
                    <tr></tr>
                    <tr>
                      
                        <td align="left" colspan="2">
                            <h2 class="style1">Create New Tour Packge</h2>
                        </td>
                    </tr>
                    
                    <tr>
                        <td align="left" width="130">Image tour</td>
                        <td align="left">
                            
                            <input  type="file" id="image" name="image"/>
                            <input type="hidden" name="todo" value="upload"/>
                            <input type="submit" name="Submit" value="Upload"/>
                            
                            <span id="imageInfor"> </span>
                        </td>
                    </tr>
                    
                </table>
                
            </form>
            
            <form id="tourPackge" action="../ControllerTourPackage" method="post">
                <table width="900px" align="center">                        
                    <tr>
                        <td></td>
                        <td align="left">
                            <% if(im !="") {
                            %><a href="../<%=im%>" class="zoom" width="400px" height="400px">
                                <img src="../<%=im%>"  width="100px" height="100px" align="left"/>
                            </a>
                            <input type="hidden" name="images" value="<%=im%>"/>
                            <%
                            }
                            %>
                        </td>
                    </tr>
                    <tr>
                        <td align="left" width="130">Tour name</td>
                        <td align="left">
                            <input  type="text" id="nameTour" name="nameTour" class="textbox"/>					
                            <span id="nameTourInfor"> What's tour name?</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">Duration tour</td>
                        <td align="left">
                            <input  type="text" id="duration" name="duration" class="textbox"/>
                            <span id="durationInfor"> What's Duration of tour?</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">Adult price</td>
                        <td align="left">
                            <input  type="text" id="adultprice" name="adultprice" class="textbox"/>(USD)
                            <span id="adultpriceInfor"> Price for Adult</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">Children price</td>
                        <td align="left">
                            <input  type="text" id="childprice" name="childprice" class="textbox"/>(USD)
                            <span id="childpriceInfor"> Price for child</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">Infor for the tour</td>
                        <td align="left">
                            <textarea  id="infor" name="infor" class="textbox" cols="60" rows="6"></textarea>
                            
                        </td>
                    </tr>
                    
                    <tr>
                        <td align="left">More description (*)</td>
                        <td align="left"><textarea id="message" name="message" cols="85" rows="18" class="textbox"></textarea></td>
                        
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <input id="send" name="send" type="submit" value="Send"/>
                            <input id="reset" name="reset" type="reset" value="reset"/>
                        </td>
                        
                    </tr>
                    
                </table>
            </form>
            
        </center>      
        
        
        
    </body>
    

    <link rel="stylesheet" href="../WebContent/css/jquery.wysiwyg.css" type="text/css" />       
    <script type="text/javascript">	
jQuery(function($){
$('a.zoom').easyZoom();

});
    </script>
</html>

